#include<bits/stdc++.h>
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
inline int read(){
  char ch=getchar();int x=0;
  while(ch<'0'||ch>'9') ch=getchar();
  int sz=1;
  while(ch>='0'&&ch<='9')
    x=x+(ch^48)*sz,ch=getchar(),sz<<=1;
  return x;
}
int n,m,x,y;
namespace solve1{
int f[1005][32][32];
void main(){
  f[0][0][0]=1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<(1<<m);j++)
      for(int k=0;k<(1<<m);k++)
        for(int l=0;l<(1<<m);l++){
          if(i==x&&l!=y) continue;
          (f[i][l][k^((j*l)&((1<<m)-1))]+=f[i-1][j][k])%=mod;
        }
  }ll ans=0;
  for(int i=0;i<(1<<m);i++)
    for(int j=0;j<(1<<m);j++)
      ans=(ans+(ll)i*f[n][j][i])%mod;
  printf("%lld",ans%mod);
}
}
namespace solve2{
struct Matrix{
  ll a[4][4];Matrix(){memset(a,0,sizeof(a));}
  ll* operator[](int x){return a[x];}
};
Matrix operator*(Matrix a,Matrix b){
  Matrix c;
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
      for(int k=0;k<4;k++)
        c[i][j]=(c[i][j]+a[i][k]*b[k][j])%mod;
  return c;
}
int p[4][4]={{1,0,1,0},{0,1,0,1},{1,0,0,1},{0,1,1,0}};
Matrix ksm(Matrix a,int k){
  Matrix s;for(int i=0;i<4;i++) s[i][i]=1;
  while(k){if(k&1) s=s*a;a=a*a;k>>=1;}return s;
}
void main(){
  Matrix a,b;
  for(int i=0;i<4;i++) for(int j=0;j<4;j++) a[i][j]=p[i][j];
  if(y==0) for(int i=0;i<4;i++) for(int j=0;j<2;j++) b[i][j]=p[i][j];
  else for(int i=0;i<4;i++) for(int j=2;j<4;j++) b[i][j]=p[i][j];
  Matrix ans=b;
  if(x) ans=ksm(a,x-1)*ans;
  if(x!=n) ans=ans*ksm(a,n-x);
  Matrix tmp=ksm(a,n-x);
  printf("%d\n",(ans[0][1]+ans[0][3])%mod);
}
}
signed LJY(){
  freopen("pearl.in","r",stdin);
  freopen("pearl.out","w",stdout);
  scanf("%d%d%d",&n,&m,&x);y=read();
  if(n<=1000&&m<=5) solve1::main();
  else if(m==1) solve2::main();
  return 0;
}